part of '../repository.dart';

const _kWebOneTimePurchasedItemTransactionRegularOfferTypeValue = 'regular';

class _WebOneTimePurchasedItemTransactionOfferTypeDto extends Equatable {
  const _WebOneTimePurchasedItemTransactionOfferTypeDto._internal({
    required this.offerTypeString,
  });

  final String offerTypeString;

  @override
  List<Object?> get props {
    return [
      offerTypeString,
    ];
  }

  factory _WebOneTimePurchasedItemTransactionOfferTypeDto.fromString(String offerTypeString) {
    return _WebOneTimePurchasedItemTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  factory _WebOneTimePurchasedItemTransactionOfferTypeDto.fromEntity(
      WebOneTimePurchasedItemTransactionOfferType offerType) {
    late final String offerTypeString;

    if (offerType == WebOneTimePurchasedItemTransactionOfferType.regular) {
      offerTypeString = _kWebOneTimePurchasedItemTransactionRegularOfferTypeValue;
    }

    return _WebOneTimePurchasedItemTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  @override
  String toString() {
    return offerTypeString;
  }

  WebOneTimePurchasedItemTransactionOfferType toEntity() {
    if (offerTypeString == _kWebOneTimePurchasedItemTransactionRegularOfferTypeValue) {
      return WebOneTimePurchasedItemTransactionOfferType.regular;
    }

    throw UnimplementedError();
  }
}
